<?php
/**
 * Bootstrap file. It starts the framework.
 * 
 * Copyright (c) 2006-2008, Julien PORTALIER
 * http://featherphp.googlecode.com/
 * 
 * Some parts are copyright (c) CakePHP,
 * http://cakephp.org/
 * 
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 */

# paths
define('DS',       DIRECTORY_SEPARATOR);
define('WWW_ROOT', dirname(__FILE__).DS);
define('APP',      dirname(WWW_ROOT).DS);
define('ROOT',     dirname(APP).DS);
define('FEATHER',  ROOT.'feather3'.DS);

define('TMP',      APP.'tmp'.DS);
define('CACHE',    TMP.'cache'.DS);

# base functions
require FEATHER.'basics.php';

# parameters cleanup
if (get_magic_quotes_gpc())
{
	cleanArray($_GET);
	cleanArray($_POST);
}

# extract URL
if (isset($_GET['url']))
{
	$url = $_GET['url'];
	if ($url === '/favicon.ico') {
		die();
	}
	unset($_GET['url']);
}
else {
	$url = '/';
}

# let's rewrite $_REQUEST
$_REQUEST = array_merge($_GET, $_POST);

# full URL prefix
$https = $_SERVER['HTTPS'];
define('PROTOCOL', 'http'.((isset($https) && $https == 'on') ? 's' : null).'://');
$httpHost = $_SERVER['HTTP_HOST'];
if (isset($httpHost))
{
	define('FULL_BASE_URL', PROTOCOL.$httpHost);
}
unset($https, $httpHost);

# feather's core
require APP.'config'.DS.'core.php';
require FEATHER.'libs'.DS.'dispatcher.php';

# dispatching
Dispatcher::init();
Dispatcher::dispatch($url);
?>